package it.polito.connectedcar.network;

import java.net.InetAddress;

public abstract class EntityNetworkConnector implements MessageReceiver{

	protected NetworkConnectionManager networkCommunicator;
	private MessagePreProcessor messageProcessor;
	
	public EntityNetworkConnector(int port) {
		networkCommunicator = new NetworkConnectionManager(port);
		networkCommunicator.setMessageReceiveListsner(this);
		messageProcessor = new ConnectedMessageProcessor();
	}
	
	
	@Override
	public void onReceive(Message message) {
		messageProcessor.processMessage(message);
	}

	public MessagePreProcessor getMessageProcessor()
	{
		return this.messageProcessor;
	}
	
	public abstract void sendMessageTo(Message message,InetAddress target,int port);
	
}
